package programs;

import java.util.List;

import programs.expression.implementedClasses.*;
import programs.expression.superClasses.Expression;
import programs.expression.superClasses.ExpressionType;
import programs.statement.*;

public class ProgramFactoryImpl implements ProgramFactory<Expression,Statement,ExpressionType> {
	
	@Override
	public Expression createDoubleLiteral(int line, int column, double d) {
		return new BasicDouble((Double) d);
	}

	@Override
	public Expression createBooleanLiteral(int line, int column, boolean b) {
		return new BasicBoolean((Boolean) b);
	}

	@Override
	public Expression createAnd(int line, int column, Expression e1, Expression e2) {
		return new AND(e1,e2);
	}

	@Override
	public Expression createOr(int line, int column, Expression e1, Expression e2) {
		return new OR(e1,e2);
	}

	@Override
	public Expression createNot(int line, int column, Expression e) {
		return new NOT(e);
	}

	@Override
	public Expression createNull(int line, int column) {
		return new NULL();
	}

	@Override
	public Expression createSelf(int line, int column) {
		return new Self();
	}

	@Override
	public Expression createGetX(int line, int column, Expression e) {
		return new GetX(e);
	}

	@Override
	public Expression createGetY(int line, int column, Expression e) {
		return new GetY(e);
	}

	@Override
	public Expression createGetVX(int line, int column, Expression e) {
		return new GetVX(e);
	}

	@Override
	public Expression createGetVY(int line, int column, Expression e) {
		return new GetVY(e);
	}

	@Override
	public Expression createGetRadius(int line, int column, Expression e) {
		return new GetRadius(e);
	}

	@Override
	public Expression createVariable(int line, int column, String name) {
		return new Variable(name);
	}

	@Override
	public Expression createLessThan(int line, int column, Expression e1, Expression e2) {
		return new SmallerThan(e1, e2);
	}

	@Override
	public Expression createGreaterThan(int line, int column, Expression e1, Expression e2) {
		return new BiggerThan(e1, e2);
	}

	@Override
	public Expression createLessThanOrEqualTo(int line, int column, Expression e1,
			Expression e2) {
		return new SmallerThanOrEqualTo(e1, e2);
	}

	@Override
	public Expression createGreaterThanOrEqualTo(int line, int column, Expression e1,
			Expression e2) {
		return new BiggerThanOrEqualTo(e1, e2);
	}

	@Override
	public Expression createEquality(int line, int column, Expression e1, Expression e2) {
		return new Equals(e1, e2);
	}

	@Override
	public Expression createInequality(int line, int column, Expression e1, Expression e2) {
		return new NotEquals(e1, e2);
	}

	@Override
	public Expression createAdd(int line, int column, Expression e1, Expression e2) {
		return new Addition(e1, e2);
	}

	@Override
	public Expression createSubtraction(int line, int column, Expression e1, Expression e2) {
		return new Subtraction(e1, e2);
	}

	@Override
	public Expression createMul(int line, int column, Expression e1, Expression e2) {
		return new Multiplication(e1, e2);
	}

	@Override
	public Expression createDivision(int line, int column, Expression e1, Expression e2) {
		return new Division(e1, e2);
	}

	@Override
	public Expression createSqrt(int line, int column, Expression e) {
		return new Sqrt(e);
	}

	@Override
	public Expression createGetDirection(int line, int column) {
		return new GetDirection();
	}

	@Override
	public Expression createSin(int line, int column, Expression e) {
		return new Sin(e);
	}

	@Override
	public Expression createCos(int line, int column, Expression e) {
		return new Cos(e);
	}

	@Override
	public Statement createEnableThruster(int line, int column) {
		return new Thrust();
	}

	@Override
	public Statement createDisableThruster(int line, int column) {
		return new ThrustOff();
	}

	@Override
	public Statement createFire(int line, int column) {
		return new Fire();
	}

	@Override
	public Statement createTurn(int line, int column, Expression angle) {
		return new Turn(angle);
	}

	@Override
	public Statement createAssignment(int line, int column, String variable,
			Expression rhs) {
		return new Assignment(rhs,variable);
	}

	@Override
	public Statement createIf(int line, int column, Expression condition, Statement then,
			Statement otherwise) {
		return new IfThenElse(condition, then, otherwise);
	}

	@Override
	public Statement createWhile(int line, int column, Expression condition,
			Statement body) {
		return new WhileLoop(body, condition);
	}

	@Override
	public Statement createForeach(int line, int column, ForeachType type,
			String variableName, Statement body) {
		Variable var = new Variable(variableName, ExpressionType.ENTITY);
		return new ForEachLoop(body, type, var);
	}

	@Override
	public Statement createSkip(int line, int column) {
		return new Skip();
	}

	@Override
	public Statement createSequence(int line, int column, List<Statement> statements) {
		return new SequenceOfStatements(statements);
	}

	@Override
	public Statement createPrint(int line, int column, Expression e) {
		return new Print(e);
	}

	@Override
	public ExpressionType createDoubleType() {
		return ExpressionType.DOUBLE;
	}

	@Override
	public ExpressionType createBooleanType() {
		return ExpressionType.BOOLEAN;
	}

	@Override
	public ExpressionType createEntityType() {
		return ExpressionType.ENTITY;
	}
}
